# -*- coding: UTF-8 -*-

import json
import os
class load_json:
    def __init__(self, path):
        self.path = path
    def show_time_nose(self):#一次只处理一张图片
        number=0
        if os.path.getsize(self.path)==0:#判断是否为空
            return str(number)
        else:#不为空
            with open(self.path) as f:
                self.pop_data = json.load(f)
            for pop_dict in self.pop_data:
                category_id = pop_dict['category_id']
                image_id = pop_dict["image_id"]
                if image_id == 1:#输出图片的id
                    if category_id == 1:
                        number += 1
            return str(number)
    def show_time_person(self):#一次只处理一张图片
        number_one,number_two=0,0
        if os.path.getsize(self.path)==0:#判断是否为空
            return str(number_one),str(number_two)
        else:#不为空
            with open(self.path) as f:
                self.pop_data = json.load(f)
            for pop_dict in self.pop_data:
                category_id = pop_dict['category_id']
                image_id = pop_dict["image_id"]
                if image_id == 1:#输入图片的id
                    if category_id == 1:
                        number_one += 1
                    elif category_id == 2:
                        number_two += 1
            return str(number_one),str(number_two)

def main():     
    filename = r"json\my_pred.json"
    #filename_ = r"json\1.json"
    acen_num,mole_num=load_json(filename).show_time_person()
    #nose_degree=load_json(filename_).show_time_nose()
    print("acen"+":"+acen_num)
    print("mole"+":"+mole_num)
if __name__=='__main__':
    main()